import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import './DetailScreen.dart';

final images = [
  "https://pic.rmb.bdstatic.com/baidu-rmb-video-cover-1/2020-4/1586341162134/162cc8271f45.jpg",
  "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584420907120&di=9b105e924f631e4ecda6e8881f0be2e0&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201604%2F24%2F20160424121701_vuhja.thumb.700_0.jpeg",
  "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584339075495&di=10d7992089fb75bb6f8fb4d69635e3ff&imgtype=0&src=http%3A%2F%2Fa0.att.hudong.com%2F64%2F76%2F20300001349415131407760417677.jpg"
];


class CustomSwiper extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ClipRRect(
      borderRadius: BorderRadius.circular(10),
      child:Swiper(
          itemBuilder: (BuildContext context, int index) {
            return Image.network(images[index],fit: BoxFit.cover);
          },
          itemCount: images.length,
          scrollDirection: Axis.horizontal,
          duration: 500,
          autoplay: true,
          onTap: (index) {
            Navigator.push(context, MaterialPageRoute(builder: (_) {
              return DetailScreen();
            }
            ));
          },
          pagination: SwiperPagination(
              alignment: Alignment.bottomCenter,
              margin: EdgeInsets.only(bottom: 2.0),
              builder: SwiperPagination.dots),
          autoplayDisableOnInteraction: true),
    );
  }
}
